﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.GamerServices; // för pause skylt
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace Group3Game
{
    class Obstacle
    {
        // Positionen på hindret.
        public Vector2 Position;

        Texture2D obstacleTexture;

        int FrameWidth;
        int FrameHeight;
        
        //public bool Active;

        public ObstacleState State; //Vilken status det är på hindret

        public enum ObstacleState
        {
            Active,
            NotActive
        }
        
        public int Damage;

        // The hit points of the enemy, if this goes to zero the enemy dies
        public int Health;

        // Get the width of the obstacle
        public int Width
        {
            get { return FrameWidth; }
        }

        // Get the height of the obstacle
        public int Height
        {
            get { return FrameHeight; }
        }
        
        float obstacleMoveSpeed;

        // Initialize the obstacle
        public void Initialize(Texture2D texture, Vector2 position, int height, int width)
        {
            // Set the starting position of the player around the middle of the screen and to the back
            Position = position;

            // Hindret
            obstacleTexture = texture;

            //obstacleMoveSpeed = 5f;
            obstacleMoveSpeed = Game1.Level + 5;

            //Active = true;

            State = ObstacleState.Active;

            Health = 1;

            Damage = 1;

            this.FrameWidth = width;
            this.FrameHeight = height;
        }

        public void Update(GameTime gameTime)
        {
            if (Player.State == Player.PlayerState.GameOver)
                return;
            // The enemy always moves to the left so decrement x
            Position.X -= obstacleMoveSpeed;

            // If the enemy is past the screen or its health reaches 0, deactivate
            if (Position.X < -Width || Health <= 0) {
                // By setting the Active flag to false, the game will remove
                //Active = false;
                State = ObstacleState.NotActive;
            }
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            //PlayerAnimation.Draw(spriteBatch);
            //base.Draw(spriteBatch);
            spriteBatch.Draw(obstacleTexture, Position, Color.White);

        }
    
    }
}
